const express = require('express')
const app = express()
const port = 3000

// 配置session中间件
const session=require("express-session")
app.use(session({
    secret:'ithema',
    resave:false,
    saveUninitialized:true
}))

app.post('/api/login', (req, res) => {
    if(req.body.username!=='admin'||req.body.password!='000000'){
        return res.send({status:1,msg:"登陆失败"})
    }
    req.session.user=req.body
    req.session.islogin=true

    return res.send({status:0,msg:"登陆成功"})
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))